<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ko">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>게시판 상세</title>
	<script src="../js/jquery.js" type="text/javascript"></script>
	<script src="../js/validator.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(function() {
			$("#deleteBtn").click(function(){
				if(!checkAuth()) return false;
				if (confirm("정말로 삭제하시겠습니까?"))
	       		{
					$('[name=mode]').val("delete");
	       		}
				else
				{
					return false;
				}    		
			});
			
			$("#deleteFileBtn").click(function(){
				if(!checkAuth()) return false;
				if (!confirm("정말로 삭제하시겠습니까?"))
	       		{
					return false;
				}    		
			});
	
			$("#commtBtn").click(function(){
				console.log("Asdf");
				
				$.ajax({      
			        type:"POST",  
			        url:"/bbs/${ bbsMap.BBS_ID }_proc.do",      
			        dataType:'json',
		            data: {	mode:'etc', 
		            		bbs_id:'${ bbsMap.BBS_ID }',
		            		article_id:'${ viewMap.ARTICLE_ID }',
		            		article_etc4:'Y'},
					success:function(args){   
						alert("수정되었습니다.");
			        }
			    });
			});
		});
		
		//img 사이지 조정
		$(window).load(function() {
			$('#view_contents').find('img').each(function(index, item) {
				
				var temp = item.width; 
		    	
				if(temp > 451)
			    {
			    	$(this).attr("width", "625px");
			    }  
			});
		});
	</script>
</head>

<body>
	<!-- 본문 영역 -->
	<div id="contents">
		<!-- 제목 및 Location 영역 -->
		<div id="location">
			<h3 id="contentTitle"></h3>
			<div id="locationPath"></div>
		</div>
		<script type="text/javascript">
		// 현재 메뉴 경로를 설정한다.
		var pagePath = licationPth.split("_");
		var pathStr = "홈";
		for( var i=0; i < pagePath.length; i++ )
		{
			if (i+1 >= pagePath.length)
				pathStr += " &gt; <strong>" + pagePath[i] + "</strong>";
			else
				pathStr += " &gt; " + pagePath[i]
		}
		document.getElementById("contentTitle").innerHTML = pagePath[ pagePath.length - 1 ];
		document.getElementById("locationPath").innerHTML = pathStr;
		</script>
		<!-- 본문 내용 -->
		<div id="content">
			<form name="writeFrm" method="post" action="../bbs/${ bbsMap.BBS_ID }_proc.do" onsubmit="return reg(this);" enctype="multipart/form-data">
			<input type="hidden" name="mode" value="edit" />
			<input type="hidden" name="bbs_id" id="bbs_id" value="${ bbsMap.BBS_ID }" />
			<input type="hidden" name="bbs_file_count" id="bbs_file_count" value="${ bbsMap.BBS_FILE_COUNT}"/>
			<input type="hidden" name="file_count" id="file_count" value="${ viewMap.FILE_COUNT}"/>
			<input type="hidden" name="file_relate_id" id="file_relate_id" value="${ viewMap.FILE_RELATE_ID}"/>
			<input type="hidden" name="article_id" id="article_id" value="${ viewMap.ARTICLE_ID }" />
			<input type="hidden" name="article_editor" id="article_editor" value="${ adminInfo.admin_name }" />
			<input type="hidden" name="article_editor_id" id="article_editor_id" value="${ adminInfo.admin_id }" />
			<input type="hidden" name="article_reg_sort" id="article_reg_sort" value="${ viewMap.ARTICLE_REG_SORT }" />
			<input type="hidden" name="article_title" value="${ viewMap.ARTICLE_TITLE }" />
			<input type="hidden" name="article_writer" value="${ viewMap.ARTICLE_WRITER }" />
			<input type="hidden" name="article_write_date" value="${ viewMap.ARTICLE_WRITE_DATE }" />
			<input type="hidden" name="article_content" value="${ viewMap.ARTICLE_CONTENT }" />
			<input type="hidden" name="article_notice_yn" id="article_notice_yn"value="N"/>
			<div class="ar"><span class="button btnProc01"></span>
			<c:if test="${ bbsMap.BBS_REPLY_YN eq 'Y' }" >
				<span class="button btnProc01"><a href="../bbs/${ bbsMap.BBS_ID }_follow.do?article_id=${viewMap.ARTICLE_ID}" id="replyBtn">답변</a></span>
			</c:if>
				<span class="button btnProc01"><input type="submit" id="deleteBtn" value="삭제" /></span>
				<%-- <span class="button btnProc01"><a href="#" onclick="checkAuth('../bbs/${ bbsMap.BBS_ID }_edit.do?article_id=${viewMap.ARTICLE_ID}');" id="btnModify">수정</a></span> --%>
				<span class="button btnProc01"><a href="../bbs/${ bbsMap.BBS_ID }_list.do">목록</a></span>
			</div>
   			<table cellspacing="0" cellpadding="0" border="0" class="tbl_type04">
				<colgroup>
					<col width="150px" />
					<col width="300px" />
					<col width="150px" />
					<col />
				</colgroup>
				<tbody>
					<tr>
						<th>제목</th>
						<td colspan="3"><c:if test="${ viewMap.ARTICLE_STEP > 0 }">[답글]</c:if><c:out value="${ viewMap.ARTICLE_TITLE }" /></td>
					</tr>
					<tr>
						<th>등록자</th>
						<td colspan="3"><c:out value="${ viewMap.ARTICLE_WRITER }" /></td>
					</tr>
					<tr>
						<th>등록일</th>
						<td><c:out value="${ viewMap.ARTICLE_WRITE_DATE }" /></td>
						<th>조회수</th>
						<td><c:out value="${ viewMap.ARTICLE_HIT }" /></td>
					</tr>
					<tr>
						<td colspan="4" id="view_contents">${ viewMap.ARTICLE_CONTENT }</td>
					</tr>
					<c:if test="${ bbsMap.BBS_FILE_COUNT ne '0'}">
					<tr>
						<th>첨부파일</th>
						<td colspan="3">
							<c:forEach items="${fileListMap}" var="fileListMap">
								<a href="../bbs/${bbsMap.BBS_ID}_file_delete.do?article_id=${ viewMap.ARTICLE_ID }&file_id=${ fileListMap.FILE_ID }" id="deleteFileBtn">[ 삭제 ]</a>&nbsp;&nbsp;<a href="/common/download.do?fileid=${fileListMap.FILE_ID}&jobid=${fileListMap.FILE_JOB_ID}"><c:out value="${fileListMap.FILE_NAME}" /><br /></a>
							</c:forEach>
						</td>
					</tr>
					</c:if>
				</tbody>
			</table>
			<c:if test="${ bbsMap.BBS_COMMENT_YN eq 'Y' }" >
			<c:import url="/bbs/comment.do">
				<c:param name="bbs_id" value="${bbsMap.BBS_ID}" />
				<c:param name="article_id" value="${viewMap.ARTICLE_ID}" />
			</c:import>
			<input type="hidden" name="returnURL" />
			</c:if>
			</form>
		</div>
	</div>
</body>
</html>